<template>
	<view class="content">
		<view style="height: 170rpx;background-color: #1262DB;">
			<view style="height: 30rpx;"></view>
			<view class="wid90 mar bacFFF borRad10">
				<uni-datetime-picker v-model="datetimerange" type="daterange" rangeSeparator="至" @change="changeTime" />
			</view>
		</view>
		<view class="dis disAl foSi40" style="height: 170rpx;justify-content: space-around;">
			<view class="textCen">
				<view style="color: #1262DB;font-weight: 600;">总收益</view>
				<view class="mar-top10">{{parseFloat(income).toFixed(2)}}</view>
			</view>
			<view class="textCen">
				<view style="color: #1262DB;font-weight: 600">总支出</view>
				<view class="mar-top10">{{parseFloat(expend).toFixed(2)}}</view>
			</view>
		</view>
		<view style="height: 100rpx;" class="wid90 mar dis disAl disJuB">
			<view class="foSi40" style="padding-left: 10rpx;border-left: 6rpx solid #1262DB;font-weight: 600;">钱包明细</view>
			<view class="">
				
			</view>
			<!-- <view @click="tiaozhuan('/pages/wallet/withdrawDeposit?tx=0')" 
				class="dis disAl disJuC borRad20 coFFF hei60 foSi30" style="width: 120rpx;background-color: #1262DB;">提现</view> -->
		</view>
		<scroll-view style="height: calc(100vh - 450rpx);" scroll-y="true" class="scroll-Y" @scrolltolower="lower">
			<view v-if="list.length == 0" class="wh100 dis disAl disJuC">
				<image src="../../static/incomeDetail/wushiju.png" style="width: 197rpx;height: 226rpx;"></image>
			</view>
			<view v-if="list.length != 0" class="foSi30 mar-top20"
				v-for="(item,index) in list" :key="index">
				<view class="wid90 mar hei60 dis disAl disJuB">
					<view>{{item.createtime}}</view>
					<view style="color: #2088f8;">金额：￥{{parseFloat(item.money).toFixed(2)}}</view>
				</view>
				<!-- <view class="wid90 mar hei60 dis disAl disJuB">
					<view style="color: #2088f8;">交易前金额：￥{{parseFloat(item.before).toFixed(2)}}</view>
					<view style="color: #2088f8;">交易后金额：￥{{parseFloat(item.after).toFixed(2)}}</view>
				</view> -->
				<view class="wid90 mar mar-top10" style="font-weight: 600;">类型：{{item.types}}</view>
				<view class="wid90 mar mar-top10" style="font-weight: 600;">订单编号：{{item.oid}}</view>
				<view class="wid90 mar mar-top10" style="color: #AEACAC;">{{item.memo}}</view>
				<view style="height: 20rpx;"></view>
				<view class="xhx"></view>
			</view>
			<view style="height: 50rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1,
				list: [],
				datetimerange: [],
				page: 0,
				income:'',
				expend:'',
				last_page: 0,
				types:''
			}
		},
		onLoad(option) {
			if(option.types){
				this.types = option.types
			}
			this.dangqian()
		},
		methods: {
			dangqian(){
				this.zhanshi = 0
				var date = new Date()
				var year = date.getFullYear()
				var month = date.getMonth() + 1
				var day = date.getDate()
				this.datetimerange = [year+'-'+month+'-'+day,year+'-'+month+'-'+day]
				this.getuserinfo()
			},
			changeTime(e) {
				this.datetimerange = e;
				if(e.length != 0){
					this.page = 0
					this.getuserinfo()
				}
			},
			getuserinfo(){
				var that = this
				uni.request({
				    url: that.global.url + 'api/wallet/details',
				    method: "POST",
					header: {
						'token': uni.getStorageSync('token')
					},
				    data: {
						begintime: this.datetimerange[0],
						endtime: this.datetimerange[1],
						page: this.page,
						types:that.types
					},
				    success(res) {
				        let result = res.data
				        if(result.code == 1){
							that.last_page = result.data.data.last_page
							that.list = result.data.data.data
							that.income = result.data.income
							that.expend = result.data.expend
						}else{
				           uni.showToast({
				           	title: result.msg,
				           	icon: 'error'
				           })
				        }
				       
				    }
				})
			},
			lower: function(e) {
				if(this.last_page != this.page+1){
					this.page++
					this.getuserinfo()
				}
			},
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				});
			},
		}
	}
</script>

<style>
	.content {}
	.uni-date-x--border {
		height: 90rpx;
	}
	.wh{
		width: 190rpx;
		height: 76rpx;
		border: 1rpx solid #AEACAC;
		color: #AEACAC;
	}
</style>
